using System;
using System.Data;

namespace Data.Model
{
    public class jsh_consume
    {
        public Int32 id { get; set; }
        public string cpuid { get; set; }
        public string bikeid { get; set; }
        public DateTime Starttime { get; set; }
        public DateTime Endtime { get; set; }
        public string lendpsam { get; set; }
        public Int32 lendpileno { get; set; }
        public Int32 lendareaid { get; set; }
        public string backpsam { get; set; }
        public Int32 backpileno { get; set; }
        public Int32 backareaid { get; set; }
        public string unlockpsam { get; set; }
        public string Status { get; set; }
        public Double Rates { get; set; }
        public Decimal Fee { get; set; }
        public Int32 deducted { get; set; }
        public string memo { get; set; }

        private string InsertSql = "insert into jsh_consume([id],[cpuID],[bikeID],[StartTime],[EndTime],[lendPSAM],[lendPileNo],[lendAreaid],[backPSAM],[backPileNo],[backareaid],[unlockPSAM],[Status],[Rates],[Fee],[deducted],[memo]) values(@id,@cpuID,@bikeID,@StartTime,@EndTime,@lendPSAM,@lendPileNo,@lendAreaid,@backPSAM,@backPileNo,@backareaid,@unlockPSAM,@Status,@Rates,@Fee,@deducted,@memo)";
        private string UpdateSql = "UPDATE jsh_consume SET [id]=@id,[cpuID]=@cpuID,[bikeID]=@bikeID,[StartTime]=@StartTime,[EndTime]=@EndTime,[lendPSAM]=@lendPSAM,[lendPileNo]=@lendPileNo,[lendAreaid]=@lendAreaid,[backPSAM]=@backPSAM,[backPileNo]=@backPileNo,[backareaid]=@backareaid,[unlockPSAM]=@unlockPSAM,[Status]=@Status,[Rates]=@Rates,[Fee]=@Fee,[deducted]=@deducted,[memo]=@memo";

        private bool _tranByConstructFlag = false;
        public bool TranByConstructFlag { get { return _tranByConstructFlag; } set { _tranByConstructFlag = value; } }
        public jsh_consume(DataRow dataRow)
        {
            if (dataRow != null)
            {
                try
                {
                    this.id = dataRow["id"] is DBNull ? 0 : Convert.ToInt32(dataRow["id"]);
                    this.cpuid = dataRow["cpuID"] is DBNull ? string.Empty : Convert.ToString(dataRow["cpuID"]);
                    this.bikeid = dataRow["bikeID"] is DBNull ? string.Empty : Convert.ToString(dataRow["bikeID"]);
                    this.Starttime = dataRow["StartTime"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(dataRow["StartTime"]);
                    this.Endtime = dataRow["EndTime"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(dataRow["EndTime"]);
                    this.lendpsam = dataRow["lendPSAM"] is DBNull ? string.Empty : Convert.ToString(dataRow["lendPSAM"]);
                    this.lendpileno = dataRow["lendPileNo"] is DBNull ? 0 : Convert.ToInt32(dataRow["lendPileNo"]);
                    this.lendareaid = dataRow["lendAreaid"] is DBNull ? 0 : Convert.ToInt32(dataRow["lendAreaid"]);
                    this.backpsam = dataRow["backPSAM"] is DBNull ? string.Empty : Convert.ToString(dataRow["backPSAM"]);
                    this.backpileno = dataRow["backPileNo"] is DBNull ? 0 : Convert.ToInt32(dataRow["backPileNo"]);
                    this.backareaid = dataRow["backareaid"] is DBNull ? 0 : Convert.ToInt32(dataRow["backareaid"]);
                    this.unlockpsam = dataRow["unlockPSAM"] is DBNull ? string.Empty : Convert.ToString(dataRow["unlockPSAM"]);
                    this.Status = dataRow["Status"] is DBNull ? string.Empty : Convert.ToString(dataRow["Status"]);
                    this.Rates = dataRow["Rates"] is DBNull ? 0 : Convert.ToDouble(dataRow["Rates"]);
                    this.Fee = dataRow["Fee"] is DBNull ? 0 : Convert.ToDecimal(dataRow["Fee"]);
                    this.deducted = dataRow["deducted"] is DBNull ? 0 : Convert.ToInt32(dataRow["deducted"]);
                    this.memo = dataRow["memo"] is DBNull ? string.Empty : Convert.ToString(dataRow["memo"]);
                    this.TranByConstructFlag = true;
                }
                catch (Exception) { this.TranByConstructFlag = false; }
            }
        }
        public jsh_consume() { }
    }
}
